<template>
  <a-card class="j-inner-table-wrapper" :bordered="false">

    <!-- 查询区域 begin -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="财务月份">
              <a-input v-model="queryParam.financialMonth" disabled />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="缴费账号">
              <a-input v-model="queryParam.accCode" placeholder="请输入缴费账号"/>
            </a-form-item>
          </a-col>
         
      
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span class="table-page-search-submitButtons table-operator">
              <a-button type="primary" icon="search" @click="searchQuery">查询</a-button>
              <a-button type="primary" icon="reload" @click="searchReset">重置</a-button>              
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域 end -->

    <!-- 操作按钮区域 begin -->
    <div class="table-operator">   
      <a-button type="primary" icon="download" @click="handleExportXls('收费记录')">导出</a-button> 
      <a-button type="primary" @click="handleCancelFee" icon="pay-circle">取消收费</a-button>    
       
    
    </div>
    <!-- 操作按钮区域 end -->

    <!-- table区域 begin -->
    <div>

      <a-alert type="info" showIcon style="margin-bottom: 16px;">
        <template slot="message">
          <span>已选择</span>
          <a style="font-weight: 600;padding: 0 4px;">{{ selectedRowKeys.length }}</a>
          <span>项</span>
          <a style="margin-left: 24px" @click="onClearSelected">清空</a>
        </template>
      </a-alert>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{x:true}"
        :loading="loading"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :expandedRowKeys="expandedRowKeys"
        :rowSelection="{selectedRowKeys, onChange: onSelectChange}"
        @expand="handleExpand"
        @change="handleTableChange"
      >

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>

        <template slot="imgSlot" slot-scope="text">
          <div style="font-size: 12px;font-style: italic;">
            <span v-if="!text">无图片</span>
            <img v-else :src="getImgView(text)" alt="" style="max-width:80px;height:25px;"/>
          </div>
        </template>


        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            ghost
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)"
          >
            <span>下载</span>
          </a-button>
        </template>
      </a-table>
    </div>
    <!-- table区域 end -->

    <!-- 表单区域 -->
    <chg-cancel-fee-modal ref="modalForm" v-bind:feeData="selectedRowKeys.join(',')" @ok="modalFormOk"/>


  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'  
  import { getAction } from '@/api/manage'
  import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
  import ChgCancelFeeModal from './modules/cancelFee/ChgCancelFeeModal'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import '@/assets/less/TableExpand.less'

  export default {
    name: 'ChgCancelFeeList',
    mixins: [JeecgListMixin],
    components: {
      JDictSelectTag,
      ChgCancelFeeModal
    },
    data() {
      return {
        description: '取消收费管理页面',
        disableMixinCreated:true,
        // 表头
        columns: [
          {
            title: '#',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: (t, r, index) => parseInt(index) + 1
          },
          {
            title: '户号',
            align: 'center',
            dataIndex: 'cusId'
          },
          {
            title: '户名',
            align: 'center',
            dataIndex: 'cusName',
          },
          {
            title: '抄表月份',
            align: 'center',
            dataIndex: 'readMonth',
          },
          {
            title: '起度',
            align: 'center',
            dataIndex: 'beginScale',
          },
          {
            title: '止度',
            align: 'center',
            dataIndex: 'endScale',
          },
          {
            title: '水量',
            align: 'center',
            dataIndex: 'amount',
          },
          {
            title: '水费',
            align: 'center',
            dataIndex: 'totalMoney',
          }, 
          {
            title: '前次余额',
            align: 'center',
            dataIndex: 'preBalance',
          },
          {
            title: '预存缴费金额',
            align: 'center',
            dataIndex: 'storedPaymentMoney',
          },
          {
            title: '违约金',
            align: 'center',
            dataIndex: 'penalty',
          },
          {
            title: '费用金额',
            align: 'center',
            dataIndex: 'money',
          },
          {
            title: '实收金额',
            align: 'center',
            dataIndex: 'recivedMoney',
          },
          {
            title: '本次余额',
            align: 'center',
            dataIndex: 'postBalance',
          },
          {
            title: '收银员',
            align: 'center',
            dataIndex: 'readerId_dictText'
          },
         
          {
            title: '缴费日期',
            align: 'center',
            dataIndex: 'financialDate',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title: '操作时间',
            align: 'center',
            dataIndex: 'status_dictText'
          },
          
        ],
        // 字典选项
        dictOptions: {},
        basePeriod:{},
        // 展开的行test
        expandedRowKeys: [],
        url: {
          list: '/chg/chgFees/cancelList',
          periodPath:'/arc/basePeriod/getPeriod',
          exportXlsUrl: '/chg/chgFees/exportXls',
       
        },
        superFieldList:[],
       
      }
    },
    created() {
      this.getSuperFieldList();
      this.getCurrentData();
    },
    computed: {
      
    },
    methods: {
      initDictConfig() {
      },
      getCurrentData(){
        this.loading = true       
        getAction(this.url.periodPath, {}).then((res) => {
          if (res.success) {
            this.basePeriod = res.result
            this.queryParam.financialMonth=this.basePeriod.month;
          }
        }).finally(() => {
          this.loading = false
        })           
      },
      handleExpand(expanded, record) {
        this.expandedRowKeys = []
        if (expanded === true) {
          this.expandedRowKeys.push(record.id)
        }
      },
      handleCancelFee(){
       
        if(this.selectedRowKeys.length>0){

          this.$refs.modalForm.add();
          this.$refs.modalForm.title = "取消收费";
          this.$refs.modalForm.disableSubmit = false;  
        }else{
           this.$message.warning("请选择需要取消的收费记录");
        }
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'cusId',text:'户号',dictCode:'mws_t_arc_customers,code,id'})
        fieldList.push({type:'string',value:'cusName',text:'户名',dictCode:''})
        fieldList.push({type:'string',value:'readMonth',text:'抄表月份',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'beginScale',text:'起度',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'endScale',text:'止度',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'amount',text:'水量',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'totalMoney',text:'合计金额',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'lajifee',text:'垃圾费',dictCode:''})
        fieldList.push({type:'string',value:'feeChargeType',text:'收费方式',dictCode:'fee_charge_type'})
        fieldList.push({type:'BigDecimal',value:'preBalance',text:'前次余额',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'storedPaymentMoney',text:'预存缴费金额',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'penalty',text:'违约金',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'money',text:'费用金额',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'recivedMoney',text:'实收金额',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'postBalance',text:'本次余额',dictCode:''})
        fieldList.push({type:'sel_user',value:'readerId',text:'抄表员'})
        fieldList.push({type:'string',value:'bookId',text:'抄表本',dictCode:''})
        fieldList.push({type:'int',value:'feeStruckStatus',text:'冲账状态',dictCode:'fee_struck_status'})
        fieldList.push({type:'string',value:'financialMonth',text:'财务月份',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'status',text:'状态',dictCode:''})
        fieldList.push({type:'string',value:'remark',text:'备注',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style lang="less" scoped>
  @import '~@assets/less/common.less';
</style>